package git.bankview.wl.report;

import java.util.*;
import java.text.*;
import java.io.*;

import laya.semi.process.*;
import git.bankview.sl.report.ReportCommon;
import git.bankview.sl.report.ReportSchd;
import git.bankview.sl.report.SchdUtil;
import git.bankview.sl.report.ReportParameter;

import git.bankview.sl.db.*;

import org.apache.log4j.Logger;

public class SchdParametersGetter
	implements IGenericClassActivity
{
	private static Logger log = Logger.getLogger(SchdParametersGetter.class);

	public void execute(IProcessContext oCtx)
		throws Exception
	{
		String[] params = oCtx.getActivityParameter().split(":");
		String schdidName = params[0];
		String jasperParamsName = params[1];
		String schdtypeName = params[2];
		String jrExportName = params[3];
		
		int nSchdId = ((Integer)oCtx.getField(schdidName)).intValue();
		Vector jasperParams = (Vector)oCtx.getField(jasperParamsName);
		String[] vJrParameters = new String[jasperParams.size()];
		
		ReportSchd oSchd = SchdUtil.getReportSchdById(nSchdId);
		Map paramValueMap = oSchd.getReportParameterMap();
		
		for (int i = 0; i < jasperParams.size(); ++i)
		{
			ReportParameter rp = (ReportParameter)jasperParams.get(i);
			rp.setDefaultInputText((String)paramValueMap.get(rp.getName()));
		}
		
		oCtx.setField(schdtypeName, new String[] {String.valueOf(oSchd.getSchdtype())});
		oCtx.setField(jrExportName, new String[] {oSchd.getSchdexport()});
	}
}
